#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    
    return;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
    int L, N;
    cin >> L >> N;
    
    vector<int> posi(N);
    for (int i = 0; i < N; i++) {
        cin >> posi[i];
    }
    int mint = 0;
    int maxt = 0;
    for (int pos : posi) {
        int curmin = min(pos, L + 1 - pos);
        if (curmin > mint) {
            mint = curmin;
        }
        int curmax = max(pos, L + 1 - pos);
        if (curmax > maxt) {
            maxt = curmax;
        }
    }
    if (N == 0) {
        mint = 0;
        maxt = 0;
    }
    cout << mint << " " << maxt << endl;
    

    return 0;
}